<!--
	o   Will contain a list of all the appointments confirmed for the user with the option to cancel them
-->
<h1>Appointment List Page</h1>
<?php
	$USRID = $_SESSION["USRID"];
	$sqlmy  = "SELECT APPOINT_DATE, NAME AS `WITH`, IF(CONFIRMED, 'CONFIRMED', 'PENDING') AS STATUS, 
		CONCAT('<small><center><a href=\"?page=appointment-detail&uapid=',UAPID,'\">[Reply]</a></center></small>') AS DETAILS 
		FROM APPOINTMENTS, USERS 
		WHERE USRID_REQUEST = USRID AND USRID_ACCEPT = $USRID
		ORDER BY APPOINT_DATE ASC;";
	$sqltheirs  = "SELECT APPOINT_DATE, NAME AS `WITH`, IF(CONFIRMED, 'CONFIRMED', 'PENDING') AS STATUS
		FROM APPOINTMENTS, USERS 
		WHERE USRID_ACCEPT = USRID AND USRID_REQUEST = $USRID  AND CONFIRMED
		ORDER BY APPOINT_DATE ASC;";
	$swaps = array();

	include('connect.php');
	$resultmy = mysql_query($sqlmy);
	$resulttheirs = mysql_query($sqltheirs);
	include('disconnect.php');
	if(!$resultmy) die("<br />ERROR535 on:<br/><pre>$sqlmy<pre><br />SQL Command Error: " . mysql_error());
	if(!$resulttheirs) die("<br />ERROR535 on:<br/><pre>$sqltheirs<pre><br />SQL Command Error: " . mysql_error());


		
	echo "<table><th><h2>Appointments at my place</th></h2></th><th><h2>My appointments at their place</h2></th>";
	echo" <tr><td>";
	printTable($resultmy, $swaps);

	echo "<br/></td><td>";
	printTable($resulttheirs, $swaps);
	echo "</td></tr></table>";
?>
